package com.briup.mt.service.impl;

import com.briup.mt.bean.BaseLog;
import com.briup.mt.bean.BaseLogExample;
import com.briup.mt.bean.DatasetFileExample;
import com.briup.mt.dao.BaseLogMapper;
import com.briup.mt.service.IBaseLogService;
import org.mockito.internal.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version 1.0
 * @auther zy
 * @date 2020/12/16 11:09
 */
@Service
public class BaseLogServiceImpl implements IBaseLogService  {
   @Resource
   private BaseLogMapper baseLogMapper;

    @Override
    public List<BaseLog> query(String realname) {
        BaseLogExample example=new BaseLogExample();
        if(!StringUtils.isEmpty(realname)){
            example.createCriteria().andRealnameLike("%" + realname + "%");
        }
       return baseLogMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(BaseLog baseLog) {
        if (baseLog.getId() == null) {
            baseLogMapper.insert(baseLog);
        }else{
            baseLogMapper.updateByPrimaryKey(baseLog);
        }
    }

    @Override
    public void deleteById(long id) {
        baseLogMapper.deleteByPrimaryKey(id);
    }
}
